//
//  GYInvoiceTableViewCell.m
//  GoodLuck
//
//  Created by apple on 2018/3/28.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

static NSString *invoiceCellIdentifier = @"invoiceCellIdentifier";

#import "GYInvoiceTableViewCell.h"
#import "GYNetWorkTools.h"

@interface GYInvoiceTableViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *stateImageView;
@property (weak, nonatomic) IBOutlet UILabel *invoiceTypeLable;
@property (weak, nonatomic) IBOutlet UILabel *invoiceContenLable;


@end
@implementation GYInvoiceTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    GYInvoiceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:invoiceCellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] firstObject];
    }
    
    return cell;
}


- (IBAction)deleteBtuClick:(UIButton *)sender {
    
    [EasyLodingView showLodingText:@"正在删除..."];
    [GYNetWorkTools requestDeleteInvoicr:[NSString stringWithFormat:@"%d",self.invoiceModel.inv_id] success:^(NSDictionary *obj) {
        int code = [[obj objectForKey:@"code"] intValue];
        if (code == 200) {
            [EasyLodingView hidenLoding];
            self.refreshTableViewCallBack();
        }else if (code == 400) {
            [EasyTextView showText:@"加载数据出错,请重新加载!"];
            [EasyLodingView hidenLoding];
        }
    } error:^(NSError *error) {
        [EasyTextView showText:@"加载数据出错,请重新加载!"];
        [EasyLodingView hidenLoding];
        NSLog(@"DeleteInvoicrFailed====%@",error);
    }];
}

- (void)setInvoiceModel:(GYInvoice *)invoiceModel {
    _invoiceModel = invoiceModel;
    
    if (invoiceModel.isSelectState) {
        self.stateImageView.image = [UIImage imageNamed:@"xuanzhong"];
    }else {
        self.stateImageView.image = [UIImage imageNamed:@"weixuanzhong"];
    }
    
    self.invoiceTypeLable.text = invoiceModel.inv_title;
    self.invoiceContenLable.text = invoiceModel.inv_content;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}



@end
